import { Navigate, useRoutes } from "react-router-dom"

import Login from '../components/Login'
import Main from '../components/Main'
import NotFound from "../components/404"
import About from '../components/Main/About'
import Home from '../components/Main/Home/idnex'
import News from "../components/Main/About/News"
import Vedios from "../components/Main/About/Vedios"

const routes = [
    {
        path: "/login",
        element: <Login />
    },
    {
        path: "/main",
        element: <Main />,
        children: [{
                path: "/main/about",
                element: <About />,
                children:[
                    {
                        path: "/main/about/news",
                        element: <News />
                    },
                    {
                        path: "/main/about/vedios",
                        element: <Vedios />
                    },
                ]
            },
            {
                path: "/main/home",
                element: <Home />
            },]
    },
    {
        path: "/",
        element: <Navigate to="/login" />
    },
    {
        path: "*",
        element: <NotFound />
    },
]

export default routes
//组件式
export const GetRoutes = () => {
    return useRoutes(routes)
}
//自定义Hook
export const useMyRoutes = () => {
    return useRoutes(routes)
}